package com.sdx.console.activity.entity;

import java.util.Date;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.beetl.sql.core.annotatoin.ColumnIgnore;
import org.beetl.sql.core.annotatoin.AutoID;
import org.beetl.sql.core.annotatoin.SeqID;
import org.apache.commons.lang3.StringUtils;
import com.ibeetl.admin.core.util.ValidateConfig;
import com.sdx.service.ConfigService;

import org.beetl.sql.core.TailBean;
import java.math.*;

import com.ibeetl.admin.core.annotation.Dict;
import com.ibeetl.admin.core.entity.BaseEntity;

import org.beetl.sql.core.annotatoin.InsertIgnore;
import org.beetl.sql.core.annotatoin.Version;
import org.beetl.sql.core.annotatoin.LogicDelete;
import com.sdx.common.utils.Utils;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;

/* 
* 
* gen by Spring Boot2 Admin 2019-05-24
*/
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@Data
public class ActivityMain extends BaseEntity{

    //活动id
    @NotNull(message = "ID不能为空", groups =ValidateConfig.UPDATE.class)
    @AutoID	
    private Integer actId ;
	
    //活动名称
    private String actName ;
	
    //活动开始时间
    private Date startTime ;
	
    //活动截止时间
    private Date endTime ;
	
    //活动类型 1、助力高考
    private Integer actType ;
	
    //其他说明
    private String actJson ;
	
    //上线状态 1、新增，2、上线，3、下线
    private Integer actStatus ;
	
    //创建人
    private Integer createdBy ;
	
    //创建人名称
    private String createdName ;
	
    //创建时间
    private Date createdTime ;
	
    //更新人
    private Integer updatedBy ;
	
    //更新人名称
    private String updatedName ;
	
    //更新时间
    private Date updatedTime ;

    private String url;

    private String explain;

    private String ruleExplain;
	
	@ColumnIgnore
	@JsonIgnore
	private String startTimeQuery;
	@ColumnIgnore
	@JsonIgnore
	private Date startTimeStart;
	@ColumnIgnore
	@JsonIgnore
	private Date startTimeEnd;
	public String getStartTimeQuery(){
		return  startTimeQuery;
	}
	public void setStartTimeQuery(String startTimeQuery ){
		this.startTimeQuery = startTimeQuery;
		Date[] timePair = Utils.parseQueryTime(startTimeQuery);
		if (timePair!=null && timePair[0]!=null) {
			this.startTimeStart = timePair[0];
		}
		if (timePair!=null && timePair.length==2 && timePair[1]!=null) {
			this.startTimeEnd = timePair[1];
		}

	}
	public Date getStartTimeStart(){
		return  startTimeStart;
	}
	public void setStartTimeStart(Date startTimeStart ){
		this.startTimeStart = startTimeStart;
	}
	public Date getStartTimeEnd(){
		return  startTimeEnd;
	}
	public void setStartTimeEnd(Date startTimeEnd ){
		this.startTimeEnd = startTimeEnd;
	}
	@ColumnIgnore
	@JsonIgnore
	private String endTimeQuery;
	@ColumnIgnore
	@JsonIgnore
	private Date endTimeStart;
	@ColumnIgnore
	@JsonIgnore
	private Date endTimeEnd;
	public String getEndTimeQuery(){
		return  endTimeQuery;
	}
	public void setEndTimeQuery(String endTimeQuery ){
		this.endTimeQuery = endTimeQuery;
		Date[] timePair = Utils.parseQueryTime(endTimeQuery);
		if (timePair!=null && timePair[0]!=null) {
			this.endTimeStart = timePair[0];
		}
		if (timePair!=null && timePair.length==2 && timePair[1]!=null) {
			this.endTimeEnd = timePair[1];
		}

	}
	public Date getEndTimeStart(){
		return  endTimeStart;
	}
	public void setEndTimeStart(Date endTimeStart ){
		this.endTimeStart = endTimeStart;
	}
	public Date getEndTimeEnd(){
		return  endTimeEnd;
	}
	public void setEndTimeEnd(Date endTimeEnd ){
		this.endTimeEnd = endTimeEnd;
	}

	public void setActJson(String actJson) {
		this.actJson = actJson;
		JSONObject json = JSON.parseObject(actJson);
		this.url = json.getString("url");
		this.explain = json.getString("explain");
		this.ruleExplain = json.getString("ruleExplain");

	}
}
